package com.qdu.mapper;

import com.qdu.bean.EverydayBean;
import org.apache.hadoop.io.LongWritable;
import org.apache.hadoop.io.Text;
import org.apache.hadoop.mapreduce.Mapper;

import java.io.IOException;

public class HolidayMapper extends Mapper<LongWritable, Text, Text, EverydayBean> {

    EverydayBean ed=new EverydayBean();

    @Override
    protected void map(LongWritable key, Text value, Context context) throws IOException, InterruptedException {
        String line = value.toString();
        String[] data = line.split(",");
        //按照日期分割
        String workday= data[2];

        //将字符串转化为整数
        int sum=Integer.parseInt(data[11]);
        int casual =Integer.parseInt(data[9]);
        int registered =Integer.parseInt(data[10]);


        context.write(new Text(workday),new EverydayBean(sum,casual,registered));

    }
}
